<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>添加店面产品</title>
<meta name="decorator" content="default" />
	<style type="text/css">
	 
		.container{
		width: 80%;
		margin: auto;
		}
	</style>
<script type="text/javascript">
	$().ready(function() {
		$("#selectProductEvent ul li").delegate("a", "click", function() {
			var item = $(this);
			document.getElementById("product-id").value = item.attr("id");
			document.getElementById("product-name").value = item.attr("name");
			document.getElementById("product-spec").value = item.attr("spec");
			document.getElementById("product-retail_price").value = item.attr("price");
			$("#selectProduct").popup("close");
		});
	});

	function checkStoreProduct() {
		var id = document.getElementById("storeProduct-id").value;
		if (id < 1) {
			alert("请先选择产品");
			return false;
		}
		var count = document.getElementById("storeProduct-count").value;
		if (count < 1) {
			alert("请输入产品数量");
			return false;
		}
		return true;
	}
</script>

</head>
<body>
 <div class="container">
	<c:if test="${!inProduct.editing}">
		<div>
			<h3 id="myModalLabel">添加产品</h3>
		</div>
		<form:form id="inventoryInForm"
			action="${ctx}/inventory/in/storeselfProduct/add"
			class="form-horizontal" modelAttribute="inProduct">

			<div>
				<form:hidden path="product.id" id="product-id" />
				<div data-role="fieldcontain">
					<label>产品名称</label>
					<form:input type="text" id="product-name" readonly="true"
						path="product.name" />
					<c:if test="${!inProduct.editing}">
						<a href="#selectProduct" data-rel="popup"
							data-position-to="window" data-transition="pop"
							data-role="button">添加产品</a>
					</c:if>
				</div>
				<div data-role="fieldcontain">
					<label>产品规格</label>
					<form:input path="product.spec" type="text" id="product-spec"
						readonly="true" />
				</div>
				<div data-role="fieldcontain">
					<label>零售价</label>
					<form:input path="product.retail_price" type="text"
						id="product-retail_price" readonly="true" />
				</div>
				<div data-role="fieldcontain">
					<label>进货价</label>
					<form:input path="price" type="text" id="inProduct_price" />
					元
				</div>
				<div data-role="fieldcontain">
					<label>进货数量</label>
					<form:input path="amount" type="text" id="storeProduct-count" />
				</div>
				<input class="btn " type="submit" value="确认添加" />&nbsp; <a
					href="${ctx}/inventory/in/product/page" data-role="button">返回</a>
			</div>
		</form:form>
		<div data-role="popup" id="selectProduct">
			<div data-role="header">
				<h1>选择店面自营产品</h1>
			</div>
			<div data-role="content" style="overflow:scroll;height:12em;"
				id="selectProductEvent">
				<ul data-role="listview" id="productsList" data-filter="true">
					<c:forEach items="${inventoryIn.storeProductList}" var="data">
						<li><a name="${data.storeSelfProduct.name}"
							spec="${data.storeSelfProduct.spec}" id="${data.id}"
							price="${data.storeSelfProduct.retail_price}" href="#">${data.storeSelfProduct.name}</a></li>
					</c:forEach>
				</ul>
			</div>
		</div>
	</c:if>
	<c:if test="${inProduct.editing}">
		<div>
			<h3 id="myModalLabel">添加产品</h3>
		</div>
		<form:form id="inventoryInForm"
			action="${ctx}/inventory/in/storeselfProduct/edit"
			class="form-horizontal" modelAttribute="inProduct">

			<div>
				<form:hidden path="product.id" id="product-id" />
				<div data-role="fieldcontain">
					<label>产品名称</label>
					<form:input type="text" id="product-name" readonly="true"
						path="product.name" />
				</div>
				<div data-role="fieldcontain">
					<label>产品规格</label>
					<form:input path="product.spec" type="text" id="product-spec"
						readonly="true" />
				</div>
				<div data-role="fieldcontain">
					<label>零售价</label>
					<form:input path="product.retail_price" type="text"
						id="product-retail_price" readonly="true" />
				</div>
				<div data-role="fieldcontain">
					<label>进货价</label>
					<form:input path="price" type="text" id="inProduct_price" />
					元
				</div>
				<div data-role="fieldcontain">
					<label>进货数量</label>
					<form:input path="amount" type="text" id="storeProduct-count" />
				</div>
				<input class="btn " type="submit" value="确认添加" />&nbsp; <a
					href="${ctx}/inventory/in/product/page" data-role="button">返回</a>
			</div>
		</form:form>

	</c:if>
	</div>
</body>
</html>
